//
//  XWTestDetailVC.m
//  XWSegmentedControlTest
//
//  Created by wzl on 2017/3/20.
//  Copyright © 2017年 亮哥. All rights reserved.
//

#import "XWTestXIBVC.h"
#import <XWSegmentedControl/XWSegmentedControl.h>

@interface XWTestXIBVC ()<XWSegmentedControlDelegate>
@property (weak, nonatomic) IBOutlet XWSegmentedControl *mySegmentedCtrl;

@end

@implementation XWTestXIBVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"xib 加载测试";
    
    NSMutableArray  *views =[[NSMutableArray alloc] init];
    NSArray *titles = @[@"测试1",@"测试2",@"测试3",@"测试4"];
    for (int i = 0; i<4; i++) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.mySegmentedCtrl.frame), [[UIScreen mainScreen] bounds].size.width, 300)];
        UILabel*label = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 21)];
        label.text = [titles objectAtIndex:i];
        [view addSubview:label];
        [self.view addSubview:view];
        [views addObject:view];
    }
    
    [self.mySegmentedCtrl setSegmentedControlTitles:titles andViews:views];
    self.mySegmentedCtrl.delegate = self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - XWSegmentedControlDelegate
- (void)segmentedControl:(XWSegmentedControl*)segmentedControl didSelectSegmentIndex:(NSInteger)segmentIndex{
    NSLog(@"选中的index=%li",segmentIndex);
}

@end
